require("../../utils/util.js");

var t = require("../../requests/request.js"), a = require("../../utils/common.js");

getApp();

Page({
    data: {
        more_view_show: "",
        more_view_hide: "more_view_hide",
        loading: !1,
        winHeight: 0,
        priceItem: [ {
            id: "1",
            name: "5万以下",
            price: "0-5"
        }, {
            id: "2",
            name: "5-8万",
            price: "5-8"
        }, {
            id: "3",
            name: "8-12万",
            price: "8-12"
        }, {
            id: "4",
            name: "12-18万",
            price: "12-18"
        }, {
            id: "5",
            name: "18-25万",
            price: "18-25"
        }, {
            id: "6",
            name: "25-40万",
            price: "25-40"
        }, {
            id: "9",
            name: "40-80万",
            price: "40-80"
        }, {
            id: "8",
            name: "80万以上",
            price: "80-9999"
        } ],
        levelItem: [ {
            id: "1",
            name: "微型车",
            level: "l=1"
        }, {
            id: "2",
            name: "小型车",
            level: "l=2"
        }, {
            id: "3",
            name: "紧凑型",
            level: "l=3"
        }, {
            id: "4",
            name: "中型车",
            level: "l=5"
        }, {
            id: "5",
            name: "中大型",
            level: "l=4"
        }, {
            id: "6",
            name: "豪华车",
            level: "l=6"
        }, {
            id: "7",
            name: "MPV",
            level: "l=7"
        }, {
            id: "8",
            name: "SUV",
            level: "l=8"
        } ],
        countryItem: [ {
            id: "4",
            name: "德系",
            country: "c=4"
        }, {
            id: "5",
            name: "日系",
            country: "c=2"
        }, {
            id: "6",
            name: "韩系",
            country: "c=16"
        }, {
            id: "7",
            name: "美系",
            country: "c=8"
        }, {
            id: "8",
            name: "欧系",
            country: "c=484"
        }, {
            id: "3",
            name: "非日系",
            country: "c=509"
        } ],
        tItem: [ {
            id: "1",
            name: "自动挡",
            t: "t=126"
        }, {
            id: "2",
            name: "手动挡",
            t: "t=1"
        } ],
        bItem: [ {
            id: "1",
            name: "两厢",
            b: "b=1"
        }, {
            id: "2",
            name: "三厢",
            b: "b=2"
        }, {
            id: "3",
            name: "旅行版",
            b: "b=8"
        } ],
        dItem: [ {
            id: "1",
            name: "1.3L以下",
            d: "d=0-1.3"
        }, {
            id: "2",
            name: "1.3-1.6L",
            d: "d=1.3-1.6"
        }, {
            id: "3",
            name: "1.7-2.0L",
            d: "d=1.7-2.0"
        }, {
            id: "4",
            name: "2.1-3.0L",
            d: "d=2.1-3.0"
        }, {
            id: "5",
            name: "3.1-5.0L",
            d: "d=3.1-5.0"
        }, {
            id: "6",
            name: "5.0L以上",
            d: "d=5.0-9"
        } ],
        fItem: [ {
            id: "1",
            name: "汽油",
            f: "f=7"
        }, {
            id: "2",
            name: "柴油",
            f: "f=8"
        }, {
            id: "3",
            name: "纯电动",
            f: "f=16"
        }, {
            id: "4",
            name: "插电混合",
            f: "f=128"
        }, {
            id: "5",
            name: "油电混合",
            f: "f=2"
        }, {
            id: "6",
            name: "天然气",
            f: "f=256"
        } ],
        dtItem: [ {
            id: "1",
            name: "前驱",
            dt: "dt=1"
        }, {
            id: "2",
            name: "后驱",
            dt: "dt=2"
        }, {
            id: "3",
            name: "四驱",
            dt: "dt=252"
        } ],
        gItem: [ {
            id: "1",
            name: "国产",
            g: "g=1"
        }, {
            id: "2",
            name: "合资",
            g: "g=2"
        }, {
            id: "3",
            name: "进口",
            g: "g=4"
        } ],
        pfItem: [ {
            id: "1",
            name: "国5",
            pf: "120"
        }, {
            id: "2",
            name: "国4",
            pf: "121"
        }, {
            id: "3",
            name: "国3",
            pf: "122"
        } ],
        gqxsItem: [ {
            id: "1",
            name: "自然吸气",
            gqxs: "100"
        }, {
            id: "2",
            name: "涡轮增压",
            gqxs: "101"
        }, {
            id: "3",
            name: "机械增压",
            gqxs: "102"
        } ],
        zwItem: [ {
            id: "1",
            name: "2座",
            zw: "279"
        }, {
            id: "2",
            name: "4-5座",
            zw: "280_281"
        }, {
            id: "3",
            name: "6座",
            zw: "282"
        }, {
            id: "4",
            name: "7座",
            zw: "283"
        }, {
            id: "5",
            name: "7座以上",
            zw: "284"
        } ],
        zw: null,
        currentzw: 0,
        pf: null,
        currentpf: 0,
        g: null,
        currentg: 0,
        dt: null,
        currentdt: 0,
        f: null,
        currentf: 0,
        d: null,
        currentd: 0,
        b: null,
        currentb: 0,
        t: null,
        currentt: 0,
        currentPrice: 0,
        price: null,
        currentLevel: 0,
        level: null,
        currentCountry: 0,
        country: null,
        currentgqxs: 0,
        gqxs: null,
        resultData: -1,
        carloading: !0,
        pagesource: ""
    },
    onShareAppMessage: function() {
        return {
            title: "个性化选车",
            path: "/pages/xuanche/xuanche?pagesource=wxshare"
        };
    },
    onLoad: function(t) {
        var a = this, e = "";
        t.pagesource && (e = t.pagesource), wx.getSystemInfo({
            success: function(t) {
                a.setData({
                    winHeight: t.windowHeight,
                    pagesource: e
                });
            }
        }), a.loadBrandData();
    },
    onPullDownRefresh: function() {
        this.loadBrandData(), wx.stopPullDownRefresh();
    },
    loadBrandData: function() {
        var a = this;
        a.setData({
            loading: !0
        }), t.getCarSelect(a.getparams(), function(t) {
            console.log(t), a.setData({
                resultData: t.Data.SerialCount,
                carloading: !1
            });
        });
    },
    onReady: function() {},
    navClick: function() {
        var t = "../tiaojianxuanche/tiaojianxuanche", a = this.getparams();
        "" != a && (t += "?" + a.substring(1, a.length)), wx.navigateTo({
            url: t
        });
    },
    resetClick: function() {
        var t = this;
        t.setData({
            zw: null,
            currentzw: 0
        }), t.setData({
            pf: null,
            currentpf: 0
        }), t.setData({
            g: null,
            currentg: 0
        }), t.setData({
            dt: null,
            currentdt: 0
        }), t.setData({
            f: null,
            currentf: 0
        }), t.setData({
            d: null,
            currentd: 0
        }), t.setData({
            b: null,
            currentb: 0
        }), t.setData({
            t: null,
            currentt: 0
        }), t.setData({
            price: null,
            currentPrice: 0
        }), t.setData({
            level: null,
            currentLevel: 0
        }), t.setData({
            country: null,
            currentCountry: 0
        }), t.setData({
            gqxs: null,
            currentgqxs: 0
        }), t.getData();
    },
    moreViewShowClick: function() {
        var t = this;
        t.setData({
            more_view_hide: ""
        }), t.setData({
            more_view_show: "more_view_hide"
        });
    },
    moreViewHideClick: function() {
        var t = this;
        t.setData({
            more_view_hide: "more_view_hide"
        }), t.setData({
            more_view_show: ""
        });
    },
    clickPrice: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.price, r = t.currentTarget.dataset.price;
        null == e || e != r ? a.setData({
            price: t.currentTarget.dataset.price,
            currentPrice: t.currentTarget.dataset.id
        }) : a.setData({
            price: null,
            currentPrice: 0
        }), a.getData();
    },
    clickLevel: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.level, r = t.currentTarget.dataset.level;
        null == e || e != r ? a.setData({
            level: t.currentTarget.dataset.level,
            currentLevel: t.currentTarget.dataset.id
        }) : a.setData({
            level: null,
            currentLevel: 0
        }), a.getData();
    },
    clickCountry: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.country, r = t.currentTarget.dataset.country;
        null == e || e != r ? a.setData({
            country: t.currentTarget.dataset.country,
            currentCountry: t.currentTarget.dataset.id
        }) : a.setData({
            country: null,
            currentCountry: 0
        }), a.getData();
    },
    clickGqxs: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.gqxs, r = t.currentTarget.dataset.gqxs;
        null == e || e != r ? a.setData({
            gqxs: t.currentTarget.dataset.gqxs,
            currentgqxs: t.currentTarget.dataset.id
        }) : a.setData({
            gqxs: null,
            currentgqxs: 0
        }), a.getData();
    },
    clickT: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.t, r = t.currentTarget.dataset.t;
        null == e || e != r ? a.setData({
            t: r,
            currentt: t.currentTarget.dataset.id
        }) : a.setData({
            t: null,
            currentt: 0
        }), a.getData();
    },
    clickB: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.b, r = t.currentTarget.dataset.b;
        null == e || e != r ? a.setData({
            b: r,
            currentb: t.currentTarget.dataset.id
        }) : a.setData({
            b: null,
            currentb: 0
        }), a.getData();
    },
    clickD: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.d, r = t.currentTarget.dataset.d;
        null == e || e != r ? a.setData({
            d: r,
            currentd: t.currentTarget.dataset.id
        }) : a.setData({
            d: null,
            currentd: 0
        }), a.getData();
    },
    clickF: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.f, r = t.currentTarget.dataset.f;
        null == e || e != r ? a.setData({
            f: r,
            currentf: t.currentTarget.dataset.id
        }) : a.setData({
            f: null,
            currentf: 0
        }), a.getData();
    },
    clickDT: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.dt, r = t.currentTarget.dataset.dt;
        null == e || e != r ? a.setData({
            dt: r,
            currentdt: t.currentTarget.dataset.id
        }) : a.setData({
            dt: null,
            currentdt: 0
        }), a.getData();
    },
    clickG: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.g, r = t.currentTarget.dataset.g;
        null == e || e != r ? a.setData({
            g: r,
            currentg: t.currentTarget.dataset.id
        }) : a.setData({
            g: null,
            currentg: 0
        }), a.getData();
    },
    clickPF: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.pf, r = t.currentTarget.dataset.pf;
        null == e || e != r ? a.setData({
            pf: r,
            currentpf: t.currentTarget.dataset.id
        }) : a.setData({
            pf: null,
            currentpf: 0
        }), a.getData();
    },
    clickZW: function(t) {
        var a = this;
        a.setData({
            carloading: !0
        });
        var e = a.data.zw, r = t.currentTarget.dataset.zw;
        null == e || e != r ? a.setData({
            zw: r,
            currentzw: t.currentTarget.dataset.id
        }) : a.setData({
            zw: null,
            currentzw: 0
        }), a.getData();
    },
    errImg: function(t) {
        var e = this;
        a.errImgFun(t, e, "http://res.app.yiche.com/wechatapp/async100x100.png");
    },
    getData: function() {
        var a = this;
        t.getCarSelect(a.getparams(), function(t) {
            a.setData({
                resultData: t.Data.SerialCount,
                carloading: !1
            });
        });
    },
    getparams: function() {
        var t = this, a = [];
        null != t.data.price && a.push("p=" + t.data.price), null != t.data.level && a.push(t.data.level), 
        null != t.data.country && a.push(t.data.country), null != t.data.t && a.push(t.data.t), 
        null != t.data.b && a.push(t.data.b), null != t.data.d && a.push(t.data.d), null != t.data.f && a.push(t.data.f), 
        null != t.data.dt && a.push(t.data.dt), null != t.data.g && a.push(t.data.g);
        var e = "";
        null != t.data.pf && (e += "_" + t.data.pf), null != t.data.zw && (e += "_" + t.data.zw), 
        null != t.data.gqxs && (e += "_" + t.data.gqxs), "" != e && (e = e.substring(1), 
        a.push("more=" + e));
        var r = "";
        return a.length > 0 && (r += "&" + a.join("&")), r;
    }
}), Array.prototype.contains = function(t) {
    return RegExp(t).test(this);
};